
/*  ieee.c
    For use with tm40.c
    Stephen D. Anderson --- August 2, 1994

    Function ieee.c converts floating point to IEEE 754 format or 
IEEE 754 format to floating point.  Since Turbo-C uses the same format 
with byte order reversed from HART it is only necessary to copy bytes.

    ON ENTRY:
        j is byte indicating direction of conversion.  j=0 for
            IEEE to float and j=1 for float to IEEE.
        s is pointer to array of the 4 bytes.  
        f is a pointer to the floating point number.

    ON EXIT:
        Returns nothing.


    REVISION LOG:


*/

#include "stdio.h"
#include "string.h"

    typedef unsigned char byte;

void ieee(byte j, byte *s, float *f)

{
    int i;
    byte *pf, *ps;
    pf = f; ps = s;

    if (j==0)
            /*  generate float.  */
            for (i=0; i<4; ++i) *pf++ = *(s + 3 - i);

    else
            /*  generate IEEE.  */
            for (i=0; i<4; ++i) *ps++ = *(pf + 3 - i);
   
}

